# -*- coding: utf-8 -*-
# @Time : 2021/9/17 16:38
# @Author : hello
# @Email : xxx@gmail.com
# @File : MRSX_ST_FL_005.py
# @Project : mryx_test


"""每日优鲜-验证购物车删除功能"""

from appium import webdriver
from selenium.webdriver.common import desired_capabilities
from appium.webdriver.common.mobileby import MobileBy as By
from selenium.webdriver.support.wait import WebDriverWait
from time import sleep

desired_capabilities={
    "platformName":"Android",
    "deviceName":"127.0.0.1:62025",
    "platformVersion":"5.1.1",
    "appPackage":"cn.missfresh.application",
    "appActivity":"cn.missfresh.module.base.main.view.MainActivity",
    "noReset":"True"
}
driver=webdriver.Remote("http://localhost:4723/wd/hub",desired_capabilities)
try:
    #点击肉蛋食材
    sleep(10)
    driver.implicitly_wait(30)
    rdsc=(By.XPATH,'//android.view.View[@resource-id=\"cn.missfresh.application:id/rv_small_diamond\"]/'
                   'android.widget.LinearLayout[1]')
    driver.find_element(*rdsc).click()
    sleep(5)
    #点击添加2次
    for i in range(2):
        driver.tap([(648,405),(705,441)])
        sleep(4)
    #点击购物车
    driver.tap(	[(465,1212),(543,1274)])
    sleep(3)
    #点击删除
    ss = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().text("删除")')
    driver.find_element(*ss).click()
    sleep(5)
    #点击确定
    qd= (By.ANDROID_UIAUTOMATOR, 'new UiSelector().text("确定")')
    driver.find_element(*qd).click()
    #断言
    # qd = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().text("购物车里空空如也")')


except Exception as e:
    raise e
finally:
    sleep(3)
    # driver.quit()